package designpattern.factory;

/**
 * @program: java-base->SimpleFactory
 * @description: 简单工厂
 * @author: G_Y
 * @create: 2019-08-16 16:54
 **/
public class SimpleFactory {

    private SimpleFactory(){}
    public static SimpleFactory simpleFactory = new SimpleFactory();

    public UserService getUserService(EUserServiceImpl e) {
        Class<? extends UserService> cls = e.getCls();
        try {
            return cls.newInstance();
        } catch (Exception exc) {
            throw new RuntimeException("创建实例异常");
        }
    }

}
